package com.prik.observer.order;

import com.prik.observer.order.observer.CashBackOB;
import com.prik.observer.order.observer.SendMsgOB;
import com.prik.observer.order.pojo.Order;
import com.prik.observer.order.subject.OrderPaidSubject;

/**
 * 订单支付后处理
 *
 * @author: prik
 * @create: 2019-07-25
 **/
public class OrderPaidHandler {

    private OrderPaidSubject orderPaidSubject;

    private OrderPaidHandler() {
    }

    private static OrderPaidHandler orderPaidHandler = new OrderPaidHandler();

    {
        orderPaidSubject = new OrderPaidSubject();
        orderPaidSubject.registerObserver(new CashBackOB());
        orderPaidSubject.registerObserver(new SendMsgOB());
    }

    public static OrderPaidHandler getInstance() {
        return orderPaidHandler;
    }

    public void orderIsPaid(Order order) {
        orderPaidSubject.notifyObservers(order);
    }
}